﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Model;

namespace BusinessLogic.Command
{
    public class GetPersonalInfoCommand : BaseCommand<APP_PERSONAL>
    {
        private int _id { get; set; }
        private string _hash { get; set; }

        public GetPersonalInfoCommand(int ID)
        {
            _id = ID;
        }

        public GetPersonalInfoCommand(string Hash)
        {
            _hash = Hash;
        }

        public override void Command()
        {
            CubeOfDB2Entities ctx = new CubeOfDB2Entities();

            if(_id != null && _id != 0)
                Result = ctx.APP_PERSONAL.Where(o => o.ID == _id).FirstOrDefault();
            else
                Result = ctx.APP_PERSONAL.Where(o => o.HASH == _hash).FirstOrDefault();
        }
    }
}
